﻿function contextMenuClicked( data,tab ){
	chrome.tabs.executeScript(null,{
		"file":"/scripts/clickDataGather.js"
	});
	chrome.windows.create({
		url : "share.html",
		width : 740,
		height : 520,
		top :Math.max(0,(screen.height - 520)/2)
	},function( newwin ){
		var port = chrome.extension.connect({name:"quickshare"});	
		port.postMessage({onClickData:data,srcTab:tab});
		port.disconnect();
	});
}

//function contextMenuClicked( info,tab ){
	//chrome.windows.create({
		//url :　"share.html",
		//width : 700,
		//height : 700
	//},function( win ){//
		////保存选中的图片或文字内容到share.html
		//var shareviewURL = chrome.extension.getURL('share.html');
		//var views = chrome.extension.getViews();//当前扩展创建的所有的windows对象
		//for( var i=0,l=views.length;i<l;i++ ){
			//var view = views[i];
			//if( view.location.href == shareviewURL && !!!view.infoData.isSet() ){
				//view.infoData.set( info );
				//break;
			//}
		//}
	//});	
//};

chrome.contextMenus.create({
	"title":"分享到腾讯微博",
	"type":"normal",
	"contexts":["all"],
	"onclick":contextMenuClicked
});
